package pony.myfilters;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloFilter implements Filter {
	FilterConfig fConfig;
	
	@Override
	public void destroy() {
		// 不做任何事
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
			throws IOException, ServletException {
		HttpServletRequest httpRequest = (HttpServletRequest)request;
		chain.doFilter(request, response);
		PrintWriter out = ((HttpServletResponse)response).getWriter();
		out.append("<br /><b>Have a nice day... ^^\"</b><br />");
	}

	@Override
	public void init(FilterConfig fConfig) throws ServletException {
		this.fConfig = fConfig;
	}
	
}
